package ex1;


/*
 * Synchronizer used for allowing threads to go to sleep and to be waked up
 * by an cell of neighbour thread
 */
class Synchronizer{
	boolean wasSignalled = false;

	  public synchronized void doWait(){
	      if(!wasSignalled){
	        try{
		        wait();
	         } catch(InterruptedException e){
	        	 System.out.print("WTF??? exception while waiting");
	         }
	      }
	      wasSignalled = false;
	  }

	  public synchronized void doNotify(){
		  wasSignalled = true;
		  notifyAll();
	  }
}
